﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:controls="clr-namespace:DraggableWindow"
    xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    >

    <Style TargetType="controls:DragDropControl">
        <Setter Property="VerticalAlignment"
                Value="Top" />
        <Setter Property="HorizontalAlignment"
                Value="Left" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:DragDropControl">
                    <Canvas x:Name="Root">
                        <Grid x:Name="Container" Width="{TemplateBinding Width}" 
                              Height="{TemplateBinding Height}">                           
                            <ContentPresenter x:Name="Content" 
                                              Content="{TemplateBinding Content}"
                                              
                                              ContentTemplate="{TemplateBinding ContentTemplate}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />                           
                        </Grid>    
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
     
    	<SolidColorBrush x:Key="DefaultBorderBrush" Color="#FFAAAAAA"/>
   
    	<SolidColorBrush x:Key="DefaultBackgroundBrush" Color="#FFF5F5F5"/>
   
   
    	<Thickness x:Key="DefaultBorderThickness">2,2,2,2</Thickness>
   
    	<LinearGradientBrush x:Key="DefaultStatusBarBackground" StartPoint="0.5,0"
    		EndPoint="0.5,1">
    		<GradientStop Color="#FFCBD2DB"
    			Offset="0" />
    		<GradientStop Color="#FFFAFAFA"
    			Offset="1" />
    	</LinearGradientBrush>     
    	<LinearGradientBrush x:Key="DefaultTitleBackground" Opacity="0.6"
    		EndPoint="0.5,1"
    		StartPoint="0.5,0">
    		<GradientStop Color="#FFFAFAFA"
    			Offset="0" />
    		<GradientStop Color="#FFCBD2DB"
    			Offset="1" />
    	</LinearGradientBrush>        
   
    	<DataTemplate x:Key="DefaultTitleTemplate">
    		<TextBlock Foreground="#FF14316B"
    			Text="{Binding}" />
    	</DataTemplate>        
        
    <!-- CloseButton Style -->
    <Style x:Key="CloseButton"
           TargetType="Button">
        <Setter Property="Width"
                Value="30" />
        <Setter Property="Height"
                Value="12" />
        <Setter Property="HorizontalAlignment"
                Value="Left" />
        <Setter Property="VerticalAlignment"
                Value="Top" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="Button">
                    <Border Width="22"
                            Height="12"
                            CornerRadius="0,0,3,3">
                        <TextBlock Foreground="WhiteSmoke"
                                   Text="r"
                                   FontSize="10"
                                   FontFamily="Webdings"
                                   TextAlignment="Center"
                                   VerticalAlignment="Center">
                        </TextBlock>
                        <Border.Background>
                            <LinearGradientBrush EndPoint="0.5,1"
                                                 StartPoint="0.5,0">
                                <GradientStop Color="#FFDB9F96"
                                              Offset="0" />
                                <GradientStop Color="#FFBE6D5F"
                                              Offset="0.499" />
                                <GradientStop Color="#FFA63A29"
                                              Offset="0.5" />
                                <GradientStop Color="#FFbE6E5A"
                                              Offset="1" />
                            </LinearGradientBrush>
                        </Border.Background>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style TargetType="controls:PopupWindow">
        <Setter Property="VerticalAlignment"
                Value="Top" />
        <Setter Property="HorizontalAlignment"
                Value="Left" />
        <Setter Property="BorderBrush"
                Value="{StaticResource DefaultBorderBrush}" />
        <Setter Property="BorderThickness"
                Value="{StaticResource DefaultBorderThickness}" />

        <Setter Property="TitleBackground" Value="{StaticResource DefaultTitleBackground}"/>
        <Setter Property="TitleTemplate" Value="{StaticResource DefaultTitleTemplate}"/>
        <Setter Property="StatusBarBackground" Value="{StaticResource DefaultStatusBarBackground}"/>
        <Setter Property="CloseButtonStyle"
                Value="{StaticResource CloseButton}" />
        <Setter Property="Background"
                Value="{StaticResource DefaultBackgroundBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:PopupWindow">
                    <Canvas x:Name="Root">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="WindowStates">
                                <vsm:VisualState x:Name="Open" />
                                <vsm:VisualState x:Name="Closed" >
                                	<Storyboard>
                                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Root" Storyboard.TargetProperty="(UIElement.Visibility)">
                                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                                				<DiscreteObjectKeyFrame.Value>
                                					<Visibility>Collapsed</Visibility>
                                				</DiscreteObjectKeyFrame.Value>
                                			</DiscreteObjectKeyFrame>
                                		</ObjectAnimationUsingKeyFrames>
                                	</Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                     
                        <Grid x:Name="Container"
                              VerticalAlignment="Top"
                              HorizontalAlignment="Left"
                              Width="{TemplateBinding Width}"
                              Height="{TemplateBinding Height}">
                            <Border x:Name="WindowBorder"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    CornerRadius="5,5,0,0"
                                    Background="White">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="22" />
                                        <RowDefinition />
                                        <RowDefinition Height="20"
                                                       x:Name="StatusRow" />
                                    </Grid.RowDefinitions>
                                    <Grid.Resources>
                                    
                                    </Grid.Resources>
                                    <Border x:Name="TitleBar"
                                            Grid.Row="0"
                                            VerticalAlignment="Stretch"
                                            Background="{TemplateBinding TitleBackground}">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*"/>
                                                <ColumnDefinition Width="Auto"/>
                                            </Grid.ColumnDefinitions>
                                            <ContentPresenter 
                                                x:Name="TitleText"
                                                Content="{TemplateBinding Title}"
                                                              ContentTemplate="{TemplateBinding TitleTemplate}"
                                                              Margin="5 0 6 0" />
                                         
                                            <StackPanel Grid.Column="1"
                                                        x:Name="Buttons"
                                                        Orientation="Horizontal"
                                                        HorizontalAlignment="Right">
                                                <Button x:Name="CloseButton"
                                                        Grid.Column="1"
                                                        Style="{TemplateBinding CloseButtonStyle}" />
                                            </StackPanel>
                                        </Grid>
                                    </Border>
                                    <Border x:Name="ContentContainer"
                                            Grid.Row="1"
                                            Margin="1 0 1 1"
                                            Background="{TemplateBinding Background}">
                                        <ContentPresenter x:Name="Content"
                                                          Margin="{TemplateBinding Padding}"
                                                          Content="{TemplateBinding Content}" 
                                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                    </Border>
                                    <Border x:Name="StatusBar"
                                            Grid.Row="2"
                                            Height="20"
                                            Visibility="{TemplateBinding StatusVisibility}"
                                            VerticalAlignment="Bottom"
                                            Background="{TemplateBinding StatusBarBackground}"
                                            BorderThickness="0 1 0 0"
                                            BorderBrush="#ccc">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                            <ContentPresenter
                                                Grid.Column="0"
                                                x:Name="StatusBarPresenter"
                                                Content="{TemplateBinding Status}"
                                                ContentTemplate="{TemplateBinding StatusTemplate}"
                                                              Margin="2" />
                                         
                                            <Image x:Name="ResizeImage"
                                                   Width="14"
                                                   Height="14"
                                                   Grid.Column="1"
                                                   VerticalAlignment="Bottom"
                                                   HorizontalAlignment="Right"
                                                   Source="PopupControls;component/img/resize-grip.png" Stretch="None" ToolTipService.ToolTip="Resize Control" />
                                        </Grid>
                                    </Border>
                                </Grid>
                            </Border>
                        </Grid>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="StatusVisibility" Value="Visible"/>
    </Style>
    <Style TargetType="controls:ModalPopupWindow">
        <Setter Property="VerticalAlignment"
                Value="Top" />
        <Setter Property="HorizontalAlignment"
                Value="Left" />
        <Setter Property="BorderBrush"
                Value="{StaticResource DefaultBorderBrush}" />
        <Setter Property="BorderThickness"
                Value="{StaticResource DefaultBorderThickness}" />
        <Setter Property="CloseButtonStyle"
                Value="{StaticResource CloseButton}" />
        <Setter Property="TitleTemplate" Value="{StaticResource DefaultTitleTemplate}"/>
        <Setter Property="TitleBackground" Value="{StaticResource DefaultTitleBackground}"/>
        <Setter Property="StatusBarBackground" Value="{StaticResource DefaultStatusBarBackground}"/>

        <Setter Property="Background"
                Value="{StaticResource DefaultBackgroundBrush}" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="controls:ModalPopupWindow">
                    <Canvas x:Name="Root">
                        <vsm:VisualStateManager.VisualStateGroups>
                            <vsm:VisualStateGroup x:Name="ModalStates">
                                <vsm:VisualState x:Name="Normal" />
                                <vsm:VisualState x:Name="Modal">
                                    <Storyboard>
                                        <ObjectAnimationUsingKeyFrames BeginTime="00:00:00"
                                                                       Duration="00:00:00.0010000"
                                                                       Storyboard.TargetName="ModalMask"
                                                                       Storyboard.TargetProperty="(UIElement.Visibility)">
                                            <DiscreteObjectKeyFrame KeyTime="00:00:00">
                                                <DiscreteObjectKeyFrame.Value>
                                            		<Visibility>Visible</Visibility>
                                            	</DiscreteObjectKeyFrame.Value>
                                            </DiscreteObjectKeyFrame>
                                        </ObjectAnimationUsingKeyFrames>
                                    </Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>

                            <vsm:VisualStateGroup x:Name="WindowStates">
                                <vsm:VisualState x:Name="Open" />
                                <vsm:VisualState x:Name="Closed" >
                                	<Storyboard>
                                		<ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetName="Root" Storyboard.TargetProperty="(UIElement.Visibility)">
                                			<DiscreteObjectKeyFrame KeyTime="00:00:00">
                                				<DiscreteObjectKeyFrame.Value>
                                					<Visibility>Collapsed</Visibility>
                                				</DiscreteObjectKeyFrame.Value>
                                			</DiscreteObjectKeyFrame>
                                		</ObjectAnimationUsingKeyFrames>
                                	</Storyboard>
                                </vsm:VisualState>
                            </vsm:VisualStateGroup>
                        </vsm:VisualStateManager.VisualStateGroups>
                        <Rectangle x:Name="ModalMask"
                                   VerticalAlignment="Stretch"
                                   HorizontalAlignment="Stretch"
                                   Fill="LightBlue"
                                   Opacity="0.5" Visibility="Collapsed" />
                        <Grid x:Name="Container"
                              VerticalAlignment="Top"
                              HorizontalAlignment="Left"
                              Width="{TemplateBinding Width}"
                              Height="{TemplateBinding Height}">
                            <Border x:Name="WindowBorder"
                                    BorderThickness="{TemplateBinding BorderThickness}"
                                    BorderBrush="{TemplateBinding BorderBrush}"
                                    CornerRadius="5,5,0,0"
                                    Background="White">
                                <Grid>
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="22" />
                                        <RowDefinition />
                                        <RowDefinition Height="20"
                                                       x:Name="StatusRow" />
                                    </Grid.RowDefinitions>
                                    <Grid.Resources>

                                    </Grid.Resources>
                                    <Border x:Name="TitleBar"
                                            Grid.Row="0"
                                            VerticalAlignment="Stretch"
                                            Background="{TemplateBinding TitleBackground}">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition Width="*" />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                            <ContentPresenter x:Name="TitleText"
                                                              Content="{TemplateBinding Title}"
                                                              ContentTemplate="{TemplateBinding TitleTemplate}"
                                                              Margin="5 0 6 0" />
                                            <StackPanel Grid.Column="1"
                                                        x:Name="Buttons"
                                                        Orientation="Horizontal"
                                                        HorizontalAlignment="Right">
                                                <Button x:Name="CloseButton"
                                                        Grid.Column="1"
                                                        Style="{TemplateBinding CloseButtonStyle}" />
                                            </StackPanel>
                                        </Grid>
                                    </Border>
                                    <Border x:Name="ContentContainer"
                                            Grid.Row="1"
                                            Margin="1 0 1 1"
                                            Background="{TemplateBinding Background}">
                                        <ContentPresenter x:Name="Content"
                                                          Margin="1 0 1 1"
                                                          Content="{TemplateBinding Content}"
                                                          ContentTemplate="{TemplateBinding ContentTemplate}"
                                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                                          VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
                                    </Border>
                                    <Border x:Name="StatusBar"
                                            Grid.Row="2"
                                            Height="20"
                                            Visibility="{TemplateBinding StatusVisibility}"
                                            VerticalAlignment="Bottom"
                                            Background="{TemplateBinding StatusBarBackground}"
                                            BorderThickness="0 1 0 0"
                                            BorderBrush="#ccc">
                                        <Grid>
                                            <Grid.ColumnDefinitions>
                                                <ColumnDefinition />
                                                <ColumnDefinition Width="Auto" />
                                            </Grid.ColumnDefinitions>
                                            <ContentPresenter Grid.Column="0"
                                                              x:Name="StatusBarPresenter"
                                                              Content="{TemplateBinding Status}"
                                                              ContentTemplate="{TemplateBinding StatusTemplate}"
                                                              Margin="2" />

                                            <Image x:Name="ResizeImage"
                                                   Width="14"
                                                   Height="14"
                                                   Grid.Column="1"
                                                   VerticalAlignment="Bottom"
                                                   HorizontalAlignment="Right"
                                                   Source="PopupControls;component/img/resize-grip.png"
                                                   Stretch="None"
                                                   ToolTipService.ToolTip="Resize Control" />
                                        </Grid>
                                    </Border>
                                </Grid>
                            </Border>
                        </Grid>
                    </Canvas>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Setter Property="StatusVisibility"
                Value="Visible" />
    </Style>

</ResourceDictionary>